# Contributor: Peter Bui <pnutzh4x0r@gmail.com>
# Maintainer: Kiyoshi Aman <kiyoshi.aman@gmail.com>
pkgname=bitlbee
pkgver=3.6
pkgrel=0
pkgdesc="An IRC to other chat networks gateway"
url="https://www.bitlbee.org/"
arch="all"
license="GPL-2.0-or-later"
makedepends="python3 glib-dev gnutls-dev libotr-dev"
subpackages="$pkgname-dev $pkgname-doc $pkgname-otr $pkgname-openrc"
source="http://get.bitlbee.org/src/bitlbee-$pkgver.tar.gz
	$pkgname.initd
	$pkgname.confd
	"

build() {
	cd "$builddir"
	PYTHON=python3 \
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--otr=plugin \
		--prefix=/usr \
		--etcdir=/etc/bitlbee \
		--ssl=gnutls # https://bugs.bitlbee.org/ticket/886
	make
}

package() {
	cd "$builddir"
	make DESTDIR="$pkgdir" install install-etc install-dev

	install -m755 -D "$srcdir"/$pkgname.initd \
		"$pkgdir"/etc/init.d/$pkgname
	install -m644 -D "$srcdir"/$pkgname.confd \
		"$pkgdir"/etc/conf.d/$pkgname
	mkdir -p "$pkgdir"/var/lib/bitlbee
	chown nobody:nobody "$pkgdir"/var/lib/bitlbee
}

otr() {
	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/bitlbee "$subpkgdir"/usr/lib
}

sha512sums="ccbf0f23e228de2de147241f36f59744b2256cba958e2fabfba0cfa60935e55bbb7d7e20fffa54da9a345e55ffa9ca82cb62e9b99dc738ba35c6e268c6561a8d  bitlbee-3.6.tar.gz
300c3445b9be6dac41bbd6d3a3ef5b871668743d4ea68dd779962d7af941cdaac61cb7c61e7ab2610bffac6dd9accc7ef9590593aef45e6930e2f49abaf9bf40  bitlbee.initd
d86e85eecafe080d331034cfc0b1f38d8e5582772d1e1d7175d14b396e1ce3dfd1b94e8ee97ef54b85181b3eacf39bacd378a1da5014515ed909554708907991  bitlbee.confd"
